package com.project.xsf.controller;

import com.project.xsf.entity.ChatInfo;
import com.project.xsf.service.ChatInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/chatInfo")
public class ChatInfoController {
    @Autowired
    private ChatInfoService chatInfoService;
    @PostMapping("/queryChatInfo")
    public List<ChatInfo> queryChatInfo(@RequestBody Map<String,Integer> map, HttpSession session){
//        System.out.println(map.get("doctorId"));
        return chatInfoService.queryInfoByMemberId(session,map.get("doctorId"));
    }
    @PostMapping("/addChatInfo")
    public Integer addChatInfo(@RequestBody Map<String,String> map,HttpSession session){
//        System.out.println(map.get("msg"));
//        System.out.println(map.get("doctorId"));
        return chatInfoService.insertSelective(map.get("msg"),Integer.parseInt(map.get("doctorId")),session);
    }
}
